package com.lxf.cloudconfig.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 罗兴发
 * @data 2025/6/11 16:28
 * @description：获取配置文件-控制类
 */
@RestController
@CrossOrigin  //跨域
@RequestMapping("/v1")
@Slf4j
@RefreshScope //自动刷新配置
public class ConfigController {

    /**
     * 获取配置中心的配置文件信息
     */
    //获取netty端口
    @Value("${webSocket.netty.port}")
    private int port;
    //获取netty地址
    @Value("${webSocket.netty.path}")
    String webSocketPath;
    //获取es地址
    @Value("${elasticsearch.rest.uris}")
    String esPath;
    //上传文件地址
    @Value(value = "${file.upload-exc}")
    private String uploadPath;
    //获取deep秘钥
    @Value("${ai.openai.api-key}")
    private String DeepSeekApiKey;
    //获取deep地址
    @Value("${ai.openai.base-url}")
    private String DeepSeekApiUrl;
    //获取deep的model
    @Value("${ai.openai.chat.options.model}")
    private String DeepSeekApiModel;
    //获取redis集群配置中心
    @Value("${spring.redis.cluster.nodes}")
    private String redisServerNodes;
    //获取分布式锁配置文件
    @Value("${spring.redisson.cluster.nodes}")
    private String redissonServerNodes;

    /**
     * 获取redis集群接口
     * @return
     */
    @GetMapping("/getRedisServerNodes")
    public String getRedisServerNodes(){
        log.info("进入获取redis集群接口");
        return redisServerNodes;
    }

    /**
     * 获取redisson分布式锁集群接口
     * @return
     */
    @GetMapping("/getRedissonServerNodes")
    public String getRedissonServerNodes(){
        log.info("进入获取redisson分布式锁集群接口");
        return redissonServerNodes;
    }

    /**
     * 获取上传文件地址接口
     * @return
     */
    @GetMapping("/getUploadPath")
    public String getUploadPath(){
        log.info("进入获取上传文件地址接口");
        return uploadPath;
    }

    /**
     * 获取websocket的端口号
     * @return
     */
    @GetMapping("/getPort")
    public int getPort(){
        log.info("进入获取端口号接口");
        return port;
    }

    /**
     * 获取websocket的地址
     * @return
     */
    @GetMapping("/getWSPath")
    public String getWSPath(){
        log.info("进入获取ws地址接口");
        return webSocketPath;
    }

    /**
     * 获取Es的地址
     * @return
     */
    @GetMapping("/getEsPath")
    public String getEsPath(){
        log.info("进入获取ES地址接口");
        return esPath;
    }

    /**
     * 获取DeepSeek的ApiKey
     * @return
     */
    @GetMapping("/getDSApiKey")
    public String getDSApiKey(){
        log.info("进入获取DeepSeek的ApiKey接口");
        return DeepSeekApiKey;
    }

    /**
     * 获取DeepSeek的ApiUrl
     * @return
     */
    @GetMapping("/getDSApiUrl")
    public String getDSApiUrl(){
        log.info("进入获取DeepSeek的ApiUrl接口");
        return DeepSeekApiUrl;
    }

    /**
     * 获取DeepSeek的ApiKey
     * @return
     */
    @GetMapping("/getDSApiModel")
    public String getDSApiModel(){
        log.info("进入获取DeepSeek的ApiModel接口");
        return DeepSeekApiModel;
    }

}
